<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>登录—云通讯平台</title>
        <script type="text/javascript" src="__PUBLIC__/js/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/js/jquery.validate.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/js/main.js"></script>
        <link rel="stylesheet" href="__PUBLIC__/css/frontstyle.css" type="text/css" />
        <link rel="stylesheet" href="__PUBLIC__/css/zhuce.css" type="text/css"/>
        <script type="text/javascript">
            function fn_focus(ele) {
                if (ele.value == ele.defaultValue) {
                    ele.value = '';
                    ele.style.color = 'rgb(51,51,51)';
                }
            }
            function fn_blur(ele) {
                var reg = /^[\s]*$/;
                if (reg.test(ele.value) || ele.value == ele.defaultValue) {
                    ele.value = ele.defaultValue;
                    ele.style.color = 'rgb(200,200,200)';
                }
            }
            //var host = window.location.href.replace("/user/login","");
            $(document).ready(function () {
                var msg = "";
                if (msg.length > 0) {
                    alert(msg);
                }
                //固定底部位置
                var docHeight = $('body').height();
                $(window).load(function () {
                    if (docHeight <= $(window).height()) {
                        $('.footer_box').css({position: 'absolute', bottom: '0'});
                    } else {
                        $('.footer_box').css({position: 'relative', bottom: 'auto'});
                    }
                });
                $(window).resize(function () {
                    if (docHeight <= $(window).height()) {
                        $('.footer_box').css({position: 'absolute', bottom: '0'});
                    } else {
                        $('.footer_box').css({position: 'relative', bottom: 'none'});
                    }
                });

                $("#loginBtn").click(function () {
                    var result = $("#loginForm").valid();
                    var remeber = "";
                    if ($("#remeberMe").is(":checked")) {
                        remeber = "on";
                    }
                    if (result) {
                        $("#loginBtn").attr("disabled", "disabled");
                        $("#loginBtn").val("登录中...");
                        $.ajax({
                            type: "POST",
                            url: "/user/doLogin",
                            data: {loginName: $("#loginName").val(), loginPwd: $("#loginPwd").val(), loginCode: $("#loginCode").val(), remeberMe: remeber, preUrl: $("#preUrl").val()},
                            dataType: "json",
                            success: function (data) {
                                if (data.flag) {
                                    var synCode = data.syncode;
                                    if (data.url == 0) {
                                        if (synCode != null && synCode != '') {
                                            var str = encode64(synCode);
                                            if (data.preUrl.indexOf("?") > 0) {
                                                window.location.href = data.preUrl + "&ucsynlogin=" + str;
                                            } else {
                                                window.location.href = data.preUrl + "?ucsynlogin=" + str;
                                            }
                                        } else {
                                            window.location.href = data.preUrl;
                                        }
                                    } else {
                                        if (synCode != null && synCode != '') {
                                            var str = encode64(synCode);
                                            if (data.url.indexOf("?") > 0) {
                                                window.location.href = "" + data.url + "&ucsynlogin=" + str;
                                            } else {
                                                window.location.href = "" + data.url + "?ucsynlogin=" + str;
                                            }
                                        } else {
                                            window.location.href = "" + data.url;
                                        }
                                    }
                                } else {
                                    $("#loginBtn").removeAttr("disabled");
                                    $("#loginBtn").val("登  录");
                                    alert(data.msg);
                                    /*if (data.errorCount >= 3) {
                                        if ($("#loginCode").length <= 0) {
                                            addRandCode();
                                            $("#loginCode").rules("add", {required: true, messages: {required: "<b>验证码不能为空</b>"}});
                                        }
                                    }*/
                                }
                            }
                        });
                    } else {
                        return false;
                    }
                });
                $("#loginForm").validate({
                    errorElement: "span",
                    errorClass: "error_error",
                    rules: {
                        loginName: {
                            required: true,
                            isEmailOrMobel: true
                        },
                        loginPwd: {
                            required: true
                        }
                    },
                    messages: {
                        loginName: {
                            required: "<b>邮件地址不能为空</b>",
                            isEmailOrMobel: "<b>请输入正确的邮件或手机号</b>"
                        },
                        loginPwd: {
                            required: "<b>密码不能为空</b>"
                        }
                    },
                    errorPlacement: function (error, element) {
                        error.appendTo(element.parent());
                    }
                });
                if ($("#loginCode").length > 0) {
                    $("#loginCode").rules("add", {required: true, messages: {required: "<b>验证码不能为空</b>"}});
                }
            });
            function addRandCode() {
                var randCodeDl = "<dl>";
                randCodeDl = randCodeDl + "<dt><label>验证码：</label></dt>";
                randCodeDl = randCodeDl + '<dd><input type="text" class="txt" name="loginCode" id="loginCode"  onfocus="fn_focus(this);" onblur="fn_blur(this);"/><div class="checkdiv"><img src="/jcaptcha" id="randCodeImg" name="randCodeImg" onclick="refreshRandCode();" /><a href="javascript:void(0);" onclick="refreshRandCode();">换一张</a></div></dd>';
                randCodeDl = randCodeDl + "</dl>";
                $("#remeberDl").before(randCodeDl);
            }
            function refreshRandCode() {
                $('#randCodeImg').hide().attr('src', '/jcaptcha?' + Math.floor(Math.random() * 100)).fadeIn();
            }
            $(document).keyup(function (event) {
                if (event.keyCode == 13) {
                    $("#loginBtn").trigger("click");
                }
            });

        </script>
    </head>
    <body>
        <div class="wrap">
            <div class="top" id="top">
                <div class="headerbox" id="headerBox">
                    <div class="header">
                        <div class="logo"><a href="/"><img src="__PUBLIC__/images/logo.png" title="云通讯平台"/></a></div>
                        <!--div class="login_box">
                            <a href="/user/login"  rel="nofollow"  class="loginbtn">登&nbsp;录</a>
                            <a href="/user/reg/init"  rel="nofollow" class="zhuce">注&nbsp;册</a>
                        </div-->
                    </div>
                </div>
            </div>
            <div class="main">
                <div class="content1">
                    <div class="c_left">
                        <div class="tit_div">
                            <h1>登录</h1>
                        </div>
                        <div class="sign_div">
                            <div class="step1">
                                <div class="form">
                                    <input type="hidden" id="preUrl" value="toMain">
                                    <form name="form" method="post" action="" id="loginForm">
                                        <dl>
                                            <dt>
                                                <label for="regEmail">邮箱/手机：</label>
                                            </dt>
                                            <dd>
                                                <input type="text" name="loginName" id="loginName" class="txt" value="admin" onfocus="fn_focus(this);" onblur="fn_blur(this);"/>
                                            </dd>
                                        </dl>
                                        <dl>
                                            <dt>
                                                <label for="pwd">登录密码：</label>
                                            </dt>
                                            <dd>
                                                <input type="password" name="loginPwd" id="loginPwd" class="txt" />
                                            </dd>
                                        </dl>

                                        <!--dl id="remeberDl">
                                            <dt></dt>
                                            <dd>
                                                <input type="checkbox" class="checkbox" name="remeberMe" id="remeberMe" value="on" checked="checked"/>
                                                <label for="remeberMe" class="ag">记住用户名</label><a href="###" onclick="return false;" class="pwd_btn">忘记密码？</a>
                                        </dl-->
                                        <dl>
                                            <dt></dt>
                                            <dd>
                                                <input type="button" id="loginBtn" value="登&nbsp;&nbsp;录" class="yj-btn-blue btn_submit"/>
                                            </dd>
                                        </dl>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <div class="footer_box" id="footer_box">
                <div class="copyrightbox">
                    <div class="copyright">
                        <p><span><em>©</em> Copyright 2015<a href="/" title="/">拉根线</a></span><span>All Rights Reserved 拉根线技术有限公司</span></p>
                    </div>
                </div>
            </div>


        </div>
    </body>
</html>